﻿package mortal.game.view.copy.ChallengeCopy.newView
{
    import com.gengine.global.*;
    import com.mui.controls.*;
    import mortal.common.global.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.ChallengeCopy.data.*;

    public class ChallengeLineRender extends GSprite
    {
        private var _line:GImageBitmap;
        private var _posTxt:GTextFiled;
        private var _challengeData:ChallengeData;
        private var _currentIndex:int;

        public function ChallengeLineRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this._line = UIFactory.gImageBitmap("", 0, 0, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._line.dispose(param1);
            this._line = null;
            if (this._posTxt)
            {
                this._posTxt.dispose(param1);
                this._posTxt = null;
            }
            this._challengeData = null;
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            this._challengeData = param1.data;
            this._currentIndex = param1.index;
            this._line.imgUrl = "ExpeditionLine_" + ChallengeUtil.getLevelUrlByTChallenge(this._challengeData.tChallengCopy, this._currentIndex);
            this.showCurrentPos();
            return;
        }// end function

        public function showCurrentPos() : void
        {
            if (Global.isDebugModle)
            {
                if (this._posTxt == null)
                {
                    this._posTxt = UIFactory.gTextField("", 0, 0, 100, 20, this, GlobalStyle.textFormatItemGreen);
                    this._posTxt.selectable = true;
                }
                this._posTxt.text = "[" + this._currentIndex + "]" + this.x + "," + this.y;
            }
            return;
        }// end function

    }
}
